<?php

use mdm\admin\AnimateAsset;
use yii\helpers\Html;
use yii\helpers\Json;
use yii\web\YiiAsset;
use yii\widgets\DetailView;

/* @var $this yii\web\View */
/* @var $model mdm\admin\models\AuthItem */
/* @var $context mdm\admin\components\ItemController */

$context = $this->context;
$labels = $context->labels();

AnimateAsset::register($this);
YiiAsset::register($this);
$opts = Json::htmlEncode([
    'items' => $model->getItems(),
]);
$this->registerJs("var _opts = {$opts};");
$this->registerJs($this->render('_script.js'));
$animateIcon = ' <i class="glyphicon glyphicon-refresh glyphicon-refresh-animate"></i>';
?>
<style>
    input.form-control{
        border-radius: 4px;
        margin-bottom: 10px;
        height: 32px;
    }
    @media (min-width: 768px){
        .form-inline .form-control {
            display: block;
            width: 100%;
        }
    }
    .form-inline .form-control {
        margin-bottom: 5px;
    }
</style>
<div class="row">
    <div class="col-md-12">
        <div class="box no-margin">
            <div class="box-body">
                <div class="row">
                    <div class="col-sm-12">
                        <?= DetailView::widget([
                            'model' => $model,
                            'attributes' => [
                                'name',
                                'description:ntext',
                                'ruleName',
                                'data:ntext',
                            ],
                            'template' => '<tr><th style="width:25%">{label}</th><td>{value}</td></tr>',
                        ]);?>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-5">
                        <input class="form-control search" data-target="available" placeholder="<?=Yii::t('rbac-admin', 'Search for available');?>">
                        <select multiple size="20" class="form-control list" data-target="available"></select>
                    </div>
                    <div class="col-sm-2 text-center">
                        <br><br><br><br>
                        <?=Html::a('&gt;&gt;' . $animateIcon, ['assign', 'id' => $model->name], [
                            'class' => 'btn btn-success btn-assign',
                            'data-target' => 'available',
                            'title' => Yii::t('rbac-admin', 'Assign'),
                        ]);?><br><br>
                        <?=Html::a('&lt;&lt;' . $animateIcon, ['remove', 'id' => $model->name], [
                            'class' => 'btn btn-danger btn-assign',
                            'data-target' => 'assigned',
                            'title' => Yii::t('rbac-admin', 'Remove'),
                        ]);?>
                    </div>
                    <div class="col-sm-5">
                        <input class="form-control search" data-target="assigned" placeholder="<?=Yii::t('rbac-admin', 'Search for assigned');?>">
                        <select multiple size="20" class="form-control list" data-target="assigned"></select>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

